home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
User's Choice Windows CD
/
User's Choice Windows CD (CMS Software)(1993).iso
/
win_q_t
/
sw_41.zip
/
SW-41.DOC
< prev
next >
Wrap
Text File
|
1991-12-01
|
32KB
|
810 lines
SW.EXE 4.1
Warren Small
(c) 1991
This batch file utility will display up to 5 lines of "text" in a window
using its command line format or up to 20 lines using an external 'Screen
Definition' file. With either method, the color of each line can be defined
separately or as a group. Also, the colors for the window, its border, the
screen background and its border can be specified. Five different window
borders are possible and the screen background can be filled with characters.
This utility also provides functions for retrieving input from the user,
controlling batch file execution through branching and alerting the user with
various sounds.
Command line syntax:
SW [options] "text1" [options] ["text2"] [options] ["text3"] ...
External file syntax:
SW @filename [label]
One advantage of using the external file approach is that more than one
window can be displayed with only one call to SW! The screen definition can
also be written into the batch file that utilizes it so that disk space is
used optimally. The optional label shown above is used to mark different
definitions within the same file. The demo batch file, SW41DEMO.BAT, contains
many examples of both methods. See page 10 for more information.
OPTIONS
Window: /f# Foreground (0-15) /b# Background (0-7) /l# Border (0-5)
/s# Shadow (1-4) /w Wide Edge /2 Double Spacing /0 No Margin
/r# Row (1-25) /c# Col (1-80) /h# here + # /d Draw /z Zoom
Text: /t|g# Text (0-15) /e# Enhanced Text /m# Border Msg /j# Justify
Screen: /k#[ ] Clear screen with color (0-7) [char] /o# Outside edge
Other: /p#[-] Pause /a# Alert (0-9) /q... Query
/i#[var] User Input /n# Input Line /u Uppercase
Switches can be in almost any order, upper or lower case, and a space is
required between each.
A second utility, DI.EXE, is provided with SW to allow various checks on
your disk drives. DI will eliminate those annoying DOS error messages that
can mess up your beautiful SW screens from time to time. See Page 13 for the
details.
Page 1
SW.EXE 4.1
Warren Small
(c) 1991
WINDOW APPEARANCE
/F# Foreground and background colors for the window are set by the /f# and
/B# /b# switches. The color can be selected using the numbers or names. If
your command line gets to be longer than 128 characters, use the numbers
to gain some space. DOS will ignore anything past the 128th position on
the command line.
COLOR VALUES
0 or bla = Black 8 or BLA = Grey
1 or blu = Blue 9 or BLU = Bright Blue
2 or gre = Green 10 or GRE = Bright Green
3 or cya = Cyan 11 or CYA = Bright Cyan
4 or red = Red 12 or RED = Bright Red
5 or mag = Magenta 13 or MAG = Bright Magenta
6 or yel = Brown 14 or YEL = Yellow
7 or whi = White 15 or WHI = Bright White
/L# Window border type is defined by the /l# (line) switch.
/l0 - none /l1 - ┌─ /l2 - ╔═
/l3 - ╒═ /l4 - ╓─ /l5 - █▀
If a character is used instead of a number, it will be used as the
window border. (e.g. /l* or /l▓).
/S# A shadow can be added with the /s# option. If the shadow covers other
characters on the screen they will be darkened, rather than hidden.
/s1 - right, below (default if /s is used alone)
/s2 - left, below
/s3 - right, above
/s4 - left, above.
/W The /w switch will give your window a wide edge, making it 2 rows taller
and 4 columns wider. Using this option will reduce the maximum string
length to 64 and the maximum number of lines from 20 to 18 if you are
using a screen definition. The /w switch will have no effect on a window
with no border (/l0).
/2 The /2 option will add a blank line between each text line passed. The
/0 /0 switch removes the blank space between the border and first and last
lines of text. Combine /0 with the /l0 switch and the resulting window
will be only as large as needed for the text passed.
/R# The position of the window can be set using the /r# (row) and /c# (col-
/C# umn) switches. These are referenced to the upper left corner of the
window. If the window is too big to fit, these coordinates will be
adjusted by the program. Thus if you have a line that places a window in
the lower right hand corner and you want to add a shadow, just put a /s
Page 2
SW.EXE 4.1
Warren Small
(c) 1991
on the end of the line and the window will be positioned properly
without changing the row and column switch values.
If you wish to set the size of the window yourself, a second /r# and /c#
will define the bottom row and right column. If the text passed to SW
will not fit in the window, these settings will be adjusted by SW
automatically, adjusting the bottom and right sides first. If you set
only top and bottom or left and right, SW will calculate the proper
values for you.
/H# For simpler positioning, /h# (here) will set the row according to the
present cursor position adding # to it if provided. The value can be
plus or minus. Use the /h# switch when you're trying to mix screen
output from another program with an SW window. The window can be easily
placed relative to the other text and will be centered left to right
unless you use the /c# switch.
/D When a Pause, Query or User Input is utilized, the window will "popup"
on the screen and disappear when the pause finishes or the input has
been processed. If you want the window to be left on the screen, specify
the /d switch. This will draw the window instead. See below for more
information on Pause, Query and User Input.
┌───────────────────────────────────────────────────────────────────────┐
│ NOTE TO PREVIOUS USERS - Since Pause, Query and User Input windows │
│ now disappear when the function is completed, you may wish to change │
│ your batch files by adding the /D switch. │
└───────────────────────────────────────────────────────────────────────┘
/Z A special effect for SW 4.1 is Zoom Window. Sometimes called "exploding"
by other applications, this switch will cause the window to be drawn in
several steps, from small to its final size. The shadow and border are
zoomed as well with the text added when the proper size is reached.
Page 3
SW.EXE 4.1
Warren Small
(c) 1991
TEXT APPEARANCE
/T# Text color can be controlled with the /t# and /g# switches. Both use the
/G# same color table shown above and both are position sensitive. /g# will
change the text color for all text following the switch. /t# will effect
only the text string immediately after the switch. New in version 4.0,
multiple /g# switches could be used to color groups of lines. To make
"text" blink, add 128 to the color # or put a + after the color name.
(e.g. 4 for red plus 128 = 132 for blinking red or red+). The window
foreground color can also blink if desired.
/E# This switch selects the "enhanced" text color. This is the color used
when you want to highlight a character within a line. In the Query
example below the '~' character preceding the 'Y' and 'N' will cause
these characters to appear bright red (/eRED) while the rest of the text
is the default bright white. If the e parameter is omitted, SW.EXE will
use the color of the current line with the opposite intensity. There is
no limit to the number of characters that can be highlighted on each
line.
/M# A /m# preceding a text string marks the string as a Border Message. If
it is the first string in the window, it will appear at the top. If it
appears after the first line of regular text, the message will appear at
the bottom. The # must be 'l', 'r' or 'c' for left, right and center.
Center is the default if /m is used alone. The message color will be the
same as the border.
/J# Text can be justified (aligned) to the left or right as well as the
default centering. This switch works on all strings following its
position, just like /g#. /jl will align text left and /jr will line up
the text to the right. /jc would restore the default.
Page 4
SW.EXE 4.1
Warren Small
(c) 1991
SCREEN APPEARANCE
/K# The /k# switch will clear the screen using the color # and places the
cursor at the upper left corner. A single character can be added after
the # to give some texture to the screen. (e.g. /k7─ or /kwhi─) This
can make the shadow effect more interesting.
A second /k# switch on the same line can be used to set the screen
foreground color. The screen background color is limited to the first 8
but the screen foreground color can use all 16. SW /kblu /kWHI sets the
screen color to bright white on blue. This will NOT affect the current
DOS screen color.
Instead of a simple fill character for the background, a string could be
used in the form /k#string. The string can be up to 80 characters long.
Interesting patterns will result depending on the length. Lengths like
2, 4, 5, 8, 10, etc. divide into 80 evenly. Other values result in each
line being offset from the last. Don't limit yourself to just words. Use
some of the special IBM characters in different combinations. The Demo
batch file has three examples. If you want spaces within the string,
either surround the string with quotes or substitute the underscore (_)
for each space. They will be replaced by spaces before being displayed.
/O# The /o# switch will set the screen border color. All color values are
valid. Using the switch without a color will reset the border to normal.
This switch could be used alone to set or reset the border. SW /ored
will set the screen border to red. Some programs ignore the border
color, others reset it and still others set one of their own. You will
have to experiment on your own is you wish to set a special border color
for a program.
Page 5
SW.EXE 4.1
Warren Small
(c) 1991
OTHER SWITCHES
/P# The /p# switch will pause for # 10ths of a second before proceeding. If
# = 0 or is missing the program will wait for the user to press a key.
If you combine Query and Pause, the pause will occur after the query
unless the query specifies a default (See below). Adding a '-' after the
number will allow the user to interrupt the timer. e.g. /p50- will pause
for 5 seconds or less if the user presses a key. Maximum value for pause
is 300 or 30 seconds.
/Q The Query switch (/q...) allows user input of single characters. The
selected key sets the DOS Errorlevel allowing conditional branches in
your batch file.
Example: sw /eRED "Continue?" "~Yes ~No" /qyn
if errorlevel 2 goto exit
if errorlevel 1 goto next
This will wait for the user to press the 'y' or 'n' key rejecting all
other keystrokes with a 'beep'. If 'n' is pressed, Errorlevel 2 will be
set and the batch file will branch to the label ":exit". 'y' will cause
a branch to ":next".
If the '~' (tilde) character immediately follows the /q, the ESC key is
also available and will set Errorlevel 0 if pressed. Up to 70 characters
can be designated as option keys. If you wish to use the space bar or
the piping (|) and redirection (< or >) characters, enclose all the
characters in quotes. (e.g. /q"abc "). This feature is not case-sensi-
tive.
SW 4.0 added the '`' character to indicate a default choice for the
Query.
Example: sw /eRED "Continue?" "~Yes ~No" /q`yn
This makes a 'Y' the default. SW will return Errorlevel 1 if ENTER is
pressed. Also, by combining a pause with a default choice, SW will
return the default if no key is pressed before the pause time elapses.
An asterisk (*) used in the Query string acts like a wild card choice.
SW will return an Errorlevel corresponding to its position in the
string.
Example: sw /eRED "Press ~Y to Continue" "Any other key to abort" /qy*
'Y' returns Errorlevel 1 and all other keys return 2. ESC and/or a
default response could be combined with the wildcard option as well.
Pressing ENTER would then return the default choice as would a Pause
timeout.
Page 6
SW.EXE 4.1
Warren Small
(c) 1991
/I# The /i# switch will add an edit line to the window which will accept
User Input. The # defines the length of the line. This feature can be
used to ask for directory names, file names, drive letters or other
information which can then be used by the batch file. SW will put the
answer in the batch file's environment with the label ANS. You can then
use the ANS variable in your batch file. A Pause used with this feature
will occur after the input.
Example: sw "Which Directory?" /i40
if exist %ans%\nul cd %ans%
This does has some limitations since it is difficult to check the
validity of the answer from a batch file.
┌───────────────────────────────────────────────────────────────────────┐
│ NOTE TO SW 3.8 USERS: If you have used the /i# switch in your batch │
│ files, be sure to remove the line "CALL SW-ENV.BAT" since this │
│ version does not create the batch file in favor of direct manipula- │
│ tion of the environment. │
└───────────────────────────────────────────────────────────────────────┘
Optionally, with SW 4.1, you can specify your own environment variable
name with the /i# switch. The variable is indicated by a string, up to 8
characters long, placed after the number. e.g. /i24Dir gives you a 24
character field and places the answer in the environment variable DIR.
(All environment variables are shifted to upper case.) This allows you
to get more than one string before processing. Just be sure your envi-
ronment is sized properly. Check the SHELL command in your DOS manual.
The string input routine has been enhanced in SW 4.1 with INSert and
Overtype modes, improved cursor positioning (HOME, END), and use of the
ESCape key for aborting. You can detect ESC if the answer does not
appear in the environment.
/N# By default, the User Input field is placed on the last line of the box.
By using the /n# switch, the field can be placed on any line. If # is
positive, the field will appear after the string on line #. If # is
negative, the field will appear by itself on line #.
/U In some cases, you may want only uppercase characters in the answer. Use
the /u switch to do this. This can be useful when asking for a drive
letter and want to put the results on the screen for verification.
/D Pause, Query and User Input windows "popup" on the screen. See page 3 in
the Window Appearance section for a description of this switch.
Page 7
SW.EXE 4.1
Warren Small
(c) 1991
/A# The Alert switch (/a#) was enhanced for SW 4.0. The normal IBM beep will
be used if # is 0 or missing. Nine other sounds can be produced varying
from simple tones to more complex sounds using the values below.
Alert Switch Values
1 - Low Freq Tone 5 - Bweep Two
2 - Mid Freq Tone 6 - Bomb
3 - High Freq Tone 7 - Siren
4 - Bweep One 8 - Phasor
9 - Tweeter
The demo batch file gives you a chance to try them all.
Page 8
SW.EXE 4.1
Warren Small
(c) 1991
DEFAULTS
Yellow double line border on a centered blue window with white single-
spaced text. No Clear Screen, Shadow or Zoom. (/fYEL /bblu /gWHI /l2)
Example: sw /kwhi /fblu /bred /gYEL "Line 1" /tWHI "Line 2" "Line 3" /s2
This will display a blue (/fblu) on red (/bred) window with a shadow to
the left and below it (/s2). The screen color will be white (/kwhi). Lines 1
and 3 are bright yellow (/gYEL) and line 2 is bright white (/tWHI). See the
batch file SW41DEMO.BAT for many more examples.
If no text strings are passed, features such as Clear Screen (/k#),
Query (/q...), Pause (/p#), Alert (/a#), and Outside Edge (/o#) can be used
with no window output. (e.g. sw /p10 will pause for 1 second.)
Page 9
SW.EXE 4.1
Warren Small
(c) 1991
SCREEN DEFINITIONS
When you run SW41DEMO.BAT, you can easily see the advantages of using a
screen definition when you want more information displayed. All of the
switches just described are applicable in a screen definition, including
Query, Pause, and User input. The thing to remember is that the windows will
be displayed in the order that they are read from the file. If you have a
pause with the third window then the pause will take place after the third
window is displayed. Then the rest of the windows will be displayed.
The are three definitions in the demo batch file as well as a fourth
stored in the separate file SW-41.NEW. The first uses the default labels
'Display' and 'End_Display'.
:Display
_window /kcya┼ /r2 /s /bred /w /0
SW.EXE - Expanded Text Handling!
/tWHI+ Multiple Windows!
/m v 4.0
_window /r10 /s /bwhi /gblu /l1 /fred /0
/tBLU Optional Command Line Syntax:
SW @filename [label]
_window /r16 /s /bwhi /gblu /l1 /fred /0
/tBLU SW 4.0 ADDITIONAL FEATURES
/tred ───────────────────────────────────────────────────
/jl - Define the entire screen with multiple windows
using external text files.
_window /r25 /l0 /0 /p100-
- Press any key for more -
_window /r19 /bwhi /gblu /l0 /jl /0 /p100-
- Text handling can be expanded to 20 single-spaced
lines per window.
_window /r19 /bwhi /gblu /l0 /jl /0 /p100-
- Using labels, more than one definition can be
included in the same file.
_window /r19 /bwhi /gblu /l0 /jl /0
- The screen definition can be included inside the
calling batch file!
_window /r25 /l0 /0 /p200-
- Press any key to continue -
:end_display
The appearance of each window is defined on a line beginning with
'_window' and followed by a space. The switches have the same form as they
would on a command line, preceded by a slash and separated by a space. The
lines that follow will be interpreted as text until another '_window' is
found or the 'end_display' label.
The text switches can appear on the same line preceding the text. The /t
switch is used to change the color one line of text and is separated from the
text by a space. /g can be used before a text line to change the color of the
Page 10
SW.EXE 4.1
Warren Small
(c) 1991
rest of the lines. /j can be used to change the text alignment and /m is used
to specify a border message. This example has 4 pauses and defines small
windows that fit inside larger ones to change the text without redrawing the
whole window.
The second definition is an example of a simple menu, in this case,
demonstrating the sounds that can be generated with SW 4.1. It uses the
labels ':menu' and ':end_menu' to differentiate it from the other two.
:menu
_window /eRED /r12 /s /l1 /w
/mc ┤ Play a Sound ├
~Low Tone ~Mid Tone ~High Tone
Bweep ~1 Bweep ~2 ~Bomb
~Siren ~Phasor ~Tweeter
~E~S~C
:end_menu
The last definition uses the labels, '4.1' and 'end_4.1', and contains 9
windows. This is probably an extreme case but it demonstrates the power of
using the definition file to display multiple windows. Users of previous
versions of SW will recognize this screen as a conversion of the final 8
calls to SW in their demo batch files. It's faster this way, isn't it! Of
course, disk cache users will not see as much difference as those without.
:4.1
_window /kwhi░▒▓ /r2 /s /bred
SW.EXE - No More Echoes!
_window /tRED /r11 /fWHI /s
They can also be placed anywhere on the screen they'll fit!
_window /c1 /r1 /tCYA /fBLU /bcya /l1 /0 /s1
Upper Left
_window /c71 /r1 /tMAG /fGRE /bmag /l1 /0 /s2
Upper Right
_window /c71 /r23 /tblu /fBLA /bgre /l1 /0 /s4
Lower Right
_window /c1 /r23 /tcya /fMAG /byel /l1 /0 /s3
Lower Left
_window /r19 /fWHI /tYEL+ /b4 /l5
(c) 1991 Warren Small
_window /r25 /l0 /0 /p100-
- Pausing 10 seconds -
_window /r25 /l0 /0
- or less! -
:end_4.1
You will notice the /k switch on the window line has no quotes around
the fill string. This was necessary because of the way the line is processed
when using the screen definition. As before, if you need spaces within the
string, use the underscore (_) character. It will be replaced with a space.
Page 11
SW.EXE 4.1
Warren Small
(c) 1991
TIPS AND TRICKS
- Change the contents of a window without redrawing the whole thing. Use
the /l0 and /0 switches to create a window just big enough for the text and
without a border. This way you can overwrite part or all of the inside of a
window and change the text in a flash. The first screen definition above uses
this technique.
- Use the ECHO batch file command to create screen definitions 'on the
fly'. That's right. If you use the redirect character > and the redirect with
append >> you can build a screen definition while running the batch file.
Perhaps you have asked the user three questions and wish to confirm them
before proceeding. If you use the command line approach to generate the
window, you can substitute the variable names directly (SW "Drive %DR%" ...)
but this isn't possible with a text file read from the disk since SW is doing
the processing, not DOS. Use the ECHO command like this:
ECHO :Display > answer.txt
ECHO _window /s /kRED▒ /l5 /qyn>> answer.txt
ECHO /mc "SW Input">> answer.txt
ECHO "Install @ Drive %DR%%Dir%?">> answer.txt
ECHO "~Yes ~No">> answer.txt
ECHO "End_Display">> answer.txt
The first line creates the file 'answer.txt' and the following lines append
to it. Then you call SW @answer.txt. Please note that the >> is placed
directly after the end quote so there won't be a space after it in the file.
This will cause SW to display the end quote in the window which is probably
not desirable.
- You could also use the above method to display other programs' output
in an SW window. The text can be no longer than 70 characters should be less
than 20 lines. If more lines are found they are ignored. Just redirect the
program output to the file. e.g. dir c:\temp\*.exe >> answer.txt. This way
you can show the result of an operation without destroying the look of the
screen. Check near the end of SW41DEMO.BAT for an example.
- Use the Enhanced text color attribute (/e#) to display text in two
colors on the same line. You could make whole words stand out in this manner.
SW /tRED /eRED+ "~B~l~i~n~k~i~n~g Red"
Page 12
SW.EXE 4.1
Warren Small
(c) 1991
DI - Disk Information
A new addition to the SW package is the companion program DI.EXE. This
little utility will be indispensable for those batch files that require the
use of disk drive. If you've ever had your nice SW screen messed up with DOS
error messages, you'll love DI!
The program puts all the little disk checking functions in one easy to
use package. With it you can check the validity of a Drive input from the
user, drive status, and disk status. You can even access the Volume label on
a disk to verify that the user has put the proper disk in the drive. Volume
labels can be changed too. You can even make sure there's enough space for
copying files or check the PATH for a file.
SYNTAX: DI [drive:] /switch [label || filespec || size]
The first parameter indicates the drive on which the operation is to
take place. If it is left out, the default drive will be used.
/VALID - Check drive to verify its existence.
/READY - Check drive to see if a disk is present.
/WRITE - Check disk write-protect status.
/SPACE - Check disk for available space.
/EXIST - Check PATH for a file.
/MATCH_VOL - Check for proper Volume ID.
/NEW_VOL - Change Volume ID.
/DEL_VOL - Delete Volume ID.
The third parameter is used with the /SPACE, /EXIST and Volume ID
switches. Use a /D as the last parameter to display the Errorlevel returned.
Two methods can be used to check available space. You can either provide
a filespec such as c:\temp\*.exe or the number of KBytes in the form /1024.
If a filespec is provided, DI will count the number a bytes in the files
matching it and then check the drive for available space.
/EXIST expands the batch file function 'if exist'. This function will
search the PATH for the filename specified in the next parameter. This will
be useful if your batch file needs to know the capabilities of a strange
machine. The drive parameter is not used.
For the Volume ID functions, /MATCH_VOL and NEW_VOL, the third parameter
is the label to match or the new label respectively. No label name is
required for /DEL_VOL.
Each of these functions returns Errorlevel 0 if the operation was
successful and Errorlevel 1 if not. There is no screen output from this
utility except when using /D or passing bad a parameter. A short descrip-
tion of the program and the switches is displayed the latter case. If you pass
a bad parameter, DI will return Errorlevel 255.
Page 13
SW.EXE 4.1
Warren Small
(c) 1991
These programs are "shareware". If you find them to be useful, a
donation of $15 would be appreciated. This will entitle you to personal
notification of future versions and give your suggestions for enhancements
more value. Registered 3.X users can upgrade to Version 4.1 for $5. This is a
free upgrade for 4.0 users. Site licenses can be negotiated.
SW Ver. 4.1
DI Ver. 1.0 December 1, 1991
Warren Small
35 Benjamin Street
Manchester, NH 03109
CIS 71076,407
GEnie W.SMALL
Prodigy RSJW31A
SW.EXE History
3.6 - 12/31/89 First general release.
3.7 - 02/01/90 Increased text lines to 5. Colors can be specified with 3
letter codes. Added Here (/h#), Double Spacing (/2), No Margin (/0), Enhanced
text color (/e#).
3.8 - 04/22/91 Added 3 border styles, 3 shadow positions, Pause Inter-
rupt (/p#-), User Input (/i#).
4.0 - 10/31/91 User Input changed to modify environment rather than
create SW-ENV.BAT. Removed limit on Highlighting. Added custom window border
(/l#char), Border Message (/m#), Justify (/j#), Outside Edge color (/o#), 9
Alert sounds (/a#), Wide window edge (/w), Foreground color for screen (/k#
/k#), Query wildcard, default, and Pause timeout (/q*` /p#-), Window size
control (/r# /r# /c# /c#).
4.1 - 12/1/91 Enhanced User Input. Pause, Query and User Input window
changed to popup style. Added Fill String (/k#string), Zoom Window (/z),
Input Line (/n#), Uppercase Input (/u), Draw Window to override popup (/d),
custom environment variables (/i#var). New Utility added to check disks
(DI.EXE).
Page 14